package org.apache.hadoop.sangbu.rpc;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.ipc.RPC;

import java.io.IOException;

/*
 * <p>描述: 启动RPC服务</p>
 * <p>创建时间: ${date} ${time} </p>
 * <p>公司信息: <a href="https://www.zcah.com.cn/">中国信息安全测评中心-中测安华</a> </p>
 * @author <a href="mail to: sangjiacun@secemail.com" rel="nofollow">桑甲存</a>
 * @version v1.0
 */
public class Server {

    // https://img-blog.csdnimg.cn/20200418151557799.png

    public static void main(String[] args) throws IOException {
        //1. 构建RPC框架
        RPC.Builder builder = new RPC.Builder(new Configuration());
        //2. 绑定地址
        builder.setBindAddress("localhost");
        //3. 绑定端口
        builder.setPort(7777);
        //4. 绑定协议
        builder.setProtocol(ClicentNameNodeProtocol.class);
        //5. 调用协议实现类
        builder.setInstance(new ClicentNameNodeImpl());
        //6. 创建服务
        RPC.Server server = builder.build();
        //7. 启动服务
        server.start();
    }
}
